package cc.rengu.igas.route.common.enums;

/**
 * 路由规则类型枚举
 *
 * @author lizhangtao
 * @version 1.0
 * @date 20200708
 */
public enum RouteRuleTypeEnum {
    /**
     * 静态路由类型
     */
    STATIC("STATIC", "静态路由"),
    /**
     * 多路比例路由
     */
    MULTI_RATE("MULTI", "多路比例路由"),
    /**
     * 多路权重路由
     */
    SMART("INTEL", "多路权重路由"),
    /**
     * 涉及到原交易的直接按照原交易通道路由，该路由为内置的路由类型
     */
    ORIGINAL("ORIGINAL", "按原交易路由"),
    ;

    private String code;
    private String name;

    RouteRuleTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static RouteRuleTypeEnum create(String code) {
        RouteRuleTypeEnum type = null;
        if (code == null) {
            return null;
        }
        switch (code) {
            case "STATIC":
                type = STATIC;
                break;
            case "MULTI_RATE":
                type = MULTI_RATE;
                break;
            case "SMART":
                type = SMART;
                break;
            case "ORIGINAL":
                type = ORIGINAL;
                break;
            default:
                break;
        }
        return type;
    }

    public String getCode() {
        return this.code;
    }

    public String getName() {
        return name;
    }
}
